package br.com.fogas.webservice.repository.soap;

import android.content.Context;
import br.com.fogas.utils.exception.ParseXmlException;
import br.com.fogas.webservice.exception.ERaiseWebServiceException;
import br.com.fogas.webservice.exception.RespostaWebServiceException;
import br.com.fogas.webservice.exception.SemConexaoInternetException;
import br.com.fogas.webservice.exception.ServidorForaException;
import br.com.fogas.webservice.exception.TempoEsperaRespostaException;
import br.com.fogas.webservice.exception.WebServiceException;
import br.com.fogas.webservice.parser.cliente.ClienteEnvelope;
import br.com.fogas.webservice.parser.cliente.ClienteRequest;
import br.com.fogas.webservice.parser.cliente.ClienteResponse;
import br.com.fogas.webservice.repository.IRepositoryHandler;
import br.com.fogas.webservice.soap.impl.ClienteSOAP;

public class ClienteRepository implements IRepositoryHandler<ClienteResponse> {

	private Context context;
	
	private ClienteRequest request;
	
	public ClienteRepository(Context context, ClienteRequest request) {
		this.context = context;
		this.request = request;
	}
	
	@Override
	public ClienteResponse getResponse() throws SemConexaoInternetException,
			ParseXmlException, TempoEsperaRespostaException,
			ServidorForaException, RespostaWebServiceException,
			WebServiceException, ERaiseWebServiceException {
		ClienteEnvelope envelope = new ClienteEnvelope();
		envelope.body.clienteRequest = request;

		ClienteSOAP soap = new ClienteSOAP(context, envelope);
		return soap.getResponse();
	}

}
